/**
 * Description:
 * Class Name:PropertiesTest
 * Date:2022/3/6 15:32
 *
 * @author LTisme
 * @version JAVA17
 */
package 疯狂Java讲义.第8章_Java集合._8_6_增强的Map集合._8_6_4_使用Properties读写属性文件;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Properties;

public class PropertiesTest {
    public static void main(String[] args) throws Exception{
        var props = new Properties();
        props.setProperty("username", "yeeku");
        props.setProperty("password", "123456");
        // 将Properties中的key-value对保存到a.ini文件中
        props.store(new FileOutputStream("a.ini"), "comment line");

        // 新建一个Properties对象
        var props2 = new Properties();
        // 向Properties中添加属性
        props2.setProperty("gender", "male");
        // 将a.ini文件中的key-value对追加到props2中
        props2.load(new FileInputStream("a.ini"));
        System.out.println(props2);
    }
}
//{password=123456, gender=male, username=yeeku}